package cc.wanforme.st.server.config.db.dynamic;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

/**
 * @author wanne
 * @since 2021-08-17
 */
public class DynamicRoutingDatasource extends AbstractRoutingDataSource {

	private static final Logger LOGGER = LoggerFactory.getLogger(DynamicRoutingDatasource.class);
	
	@Override
	protected Object determineCurrentLookupKey() {
	    String datasource = DataSourceContextHolder.getDbType();
	    LOGGER.debug("使用数据源 {}", datasource);
	    return datasource;
	}
}
